/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tallerfinal.view.distributions;

import tallerfinal.util.enums.DistributionsName;
import tallerfinal.view.distributions.factory.GeneratorViewFactory;

/**
 *
 * @author ricardo
 */
public class TriangularView extends GeneratorView {

    static {
        GeneratorViewFactory.getInstance().registerProduct(DistributionsName.TRIANGULAR, TriangularView.class);
    }
    private Number a;
    private Number b;
    private Number c;

    /**
     * Creates new form TriangularView
     */
    public TriangularView() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        valAField = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        valBField = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        valCField = new javax.swing.JFormattedTextField();

        setBackground(new java.awt.Color(255, 255, 255));
        setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Editor Distribucion Triangular"));
        setPreferredSize(new java.awt.Dimension(200, 120));
        setLayout(new java.awt.GridLayout(3, 2));

        jLabel1.setText("A: ");
        add(jLabel1);

        valAField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        valAField.addAncestorListener( new RequestFocusListener() );
        add(valAField);

        jLabel2.setText("B: ");
        add(jLabel2);

        valBField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        add(valBField);

        jLabel3.setText("C: ");
        add(jLabel3);

        valCField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        add(valCField);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JFormattedTextField valAField;
    private javax.swing.JFormattedTextField valBField;
    private javax.swing.JFormattedTextField valCField;
    // End of variables declaration//GEN-END:variables

    @Override
    public Object[] getData() {

        a = (Number) valAField.getValue();
        b = (Number) valBField.getValue();
        c = (Number) valCField.getValue();
        return new Object[]{a.doubleValue(), b.doubleValue(), c.doubleValue()};
    }

    @Override
    public String tosString() {
        return "Distribucion Triangular a = " + a.doubleValue() + " b = " + b.doubleValue() + " c = " + c.doubleValue();



    }
}
